﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PersonExpSpecialityInfo.aspx.cs" Inherits="RN.ERP.Web.Person.PersonExpSpecialityInfo" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><%=PageTitle %></title>
    <link href="../Styles/skins/blue/css/style.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/skins/blue/css/style_msg.css" rel="stylesheet" type="text/css" />
    <link rel="Stylesheet" type="text/css" href="../Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <script src="../Scripts/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript" src="../Scripts/json-data.js"></script>
    <script type="text/javascript" src="../Scripts/iepngfix_tilebg.js"></script>
    <script src="../My97DatePicker/WdatePicker.js" type="text/javascript"></script>
     <script type="text/javascript" src="../Scripts/ligerUI/js/ligerui.min.js"></script>
    <style type="text/css">
        .IE6png
        {
            behavior: url("../Scripts/iepngfix.htc");
        }
        .tree
        {
            width:700px;
            height:320px;
            margin: 10px;
            border: 1px solid #ccc;
            overflow: auto;
        }
    </style>
    <script type="text/javascript">
    </script>
</head>
<body>
    <form id="form1" runat="server">
      <input id="hdStatus" type="hidden" runat="server" value="0" />
    <table width="870" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr>
            <td width="16" class="title_lbg IE6png">
            </td>
            <td width="24" class="title_t IE6png">
            </td>
            <td width="813" class="title_libg IE6png">
                专家专业
            </td>
            <td width="17" class="title_rbg IE6png">
            </td>
        </tr>
        <tr>
            <td class="border_lbg IE6png">
                &nbsp;
            </td>
            <td colspan="2">
                <div id="con">
                    <div id="tagContent">
                        <div class="tagContent selectTag"  id="expertSpeciality" table="tb_Expert_Speciality"
                            valtype="0">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="xx_tab">
                             <tr>
                                <td>
                                </td>
                                <td  colspan="2">
                                <div id="divsearch" runat="server" class="s_input" style="float:left;margin-right:10px">
                                        <span class="input_l">
                                            <img src="../images/input_l.jpg" width="10" height="31" alt="" /></span> <span class="input_mm">
                                                <asp:TextBox ID="txtSpecName" runat="server" Style="width: 200px; height: 31px; line-height: 31px;
                                                    border: 0; background: transparent"></asp:TextBox>
                                            </span><span class="input_r">
                                                <img src="../images/input_r.jpg" width="10" height="31" alt="" /></span>
                                  </div>
                                <input type="button" class="xtbiao" style="float:left;margin-top:6px;display:none" id="btnSearch" value="查询" />
                                </td>
                            </tr>
                            <tr>
                             <td></td>
                             <td colspan="2">
                             <label id="lblTitle"></label>
                             </td>
                            </tr>
                                <tr>
                                    <td align="right" width="67" >
                                        专业<br />名称
                                        <input id="hdEmpGuid" type="hidden" runat="server" value="" control="EmpGuid" />
                                        <input id="hdID" type="hidden" runat="server" value="0" control="ID" />
                                        <input id="hdSpecGuid" type="hidden" runat="server" value="" control="SpecialityGuid" />
                                        <input type="hidden" id="hidIsMain" runat="server" control="IsMain"  />
                                        <input type="hidden" id="hidSpecName" runat="server" control="SpecialityName" />
                                        <input type="hidden" id="hidTypeFlags" runat="server" control="TypeFlags" />
                                        <input type="hidden" id="hidSpecCode" runat="server" control="SpecialityCode" />
                                    </td>
                                   <td colspan="2">
<%--                                            <span class="input_l">
                                                <img src="../images/input_l.jpg" width="10" height="31" alt="" />
                                            </span>
                                            <span class="input_mm">
                                                    <select name="" id="selSpecialityName" runat="server" style="width: 205px; height: 20px;
                                                        line-height: 31px; margin-top: 5px; border: 0;" controltype="drop" control="TypeFlags,SpecialityName"
                                                        controlvalid="SelEmpty(this,'-1')" controltext="专业类别">
                                                        <option value="-1" vls='-1'>请选择</option>
                                                    </select>
                                            </span>--%>
                                            <div class="tree">
                                                <ul id="SpecTree">
                                                </ul>
                                            </div>
                                    </td>
                                </tr>
                            </table>
                                        <div  style="margin:0 auto; width:800px;">
                                        <div class="icon01 IE6png" style="float:left;margin-right:20px">
                                            <a id="btnSave" parentdiv="expertSpeciality" href="javascript:void(0);">保存</a>
                                        </div>
                                        <div class="icon02 IE6png" style="float:left">
                                            <a id="btnCancel" href="javascript:void(0);">关闭</a>
                                        </div>
                                        <div style="float:left;margin-left:10px">点击下载<a href="../Content/山东省建设工程评标专家专业分类标准.doc"><font color=blue>山东省建设工程评标专家专业分类标准</font></a></div>
                                        </div>
                                    
                        </div>
                    </div>
                </div>
            </td>
            <td class="border_rbg IE6png">&nbsp;</td>
        </tr>
        <tr>
            <td class="border_lconer IE6png" headers="17">
                &nbsp;
            </td>
            <td colspan="2" class="border_bottomli IE6png" height="17">
                &nbsp;
            </td>
            <td class="border_rconer IE6png" headers="17">
                &nbsp;
            </td>
        </tr>
    </table>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadAjaxLoadingPanel runat="server" ID="LoadingPanel">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadWindowManager ID="Manager1" runat="server" EnableShadow="true" Skin="WebBlue">
         
        </telerik:RadWindowManager>
    </form>
    
</body>
</html>
<script type="text/javascript">
    var empGuid;
    var status;
    var specGuid;
    var isMain;
    var manager;
    var specName;
    $(function () {
        empGuid = $("#<%= hdEmpGuid.ClientID%>").val();
        status = $("#<%= hdStatus.ClientID%>").val();
        specGuid = $("#<%= hdSpecGuid.ClientID%>").val();
        isMain = $("#<%= hidIsMain.ClientID%>").val();
        Initial();
    });
    /*初始化页面*/
    function Initial() {
        $("#btnSave").click(function () {
            ExpSpecSave("btnSave");
        });
        $("#btnCancel").click(function () {
            returnToParent(1);
        });
        if (status == "1") {
            GetExpSpec();
        }
        //结束时间输入控制
        $("#CheckEndTime").click(function () {
            if ($(this).attr("checked")) {
                $("#txtEndDate").val("至今");
                $("#txtEndDate").attr("disabled", "disabled");
            } else {
                $("#txtEndDate").val("");
                $("#txtEndDate").removeAttr("disabled");
            }
        });

        $("#SpecTree").ligerTree({
            nodeWidth: 300,
            url: '../handlers/PsnEmpInfoHandler.ashx?action=Tree&pid=0',
            attribute: ['nodename', 'id'],
            onBeforeExpand: onBeforeExpand,
            isExpand: function (e) {
                var data = e.data;
                return data.isexpand;
            },
            onCheck: onCheck,
            checkbox: true,
            single: true,
            slide: true
        });
        manager = $("#SpecTree").ligerGetTreeManager();
        $("#btnSearch").click(function () {
            var psid;
            var specName = escape($("#txtSpecName").val());
            manager = $("#SpecTree").ligerGetTreeManager();
            $.getJSON("PersonExpSpecialityInfo.aspx", { "action": "GetSpecDics", "empGuid": empGuid, "specGuid": specGuid, "isMain": isMain, "specName": specName, "rand": Math.random() }, function (data) {
                if (data.Result == true) {
                    manager.clear();
                    manager.loadData(null, "../handlers/PsnEmpInfoHandler.ashx?action=LoadSpecDics&empGuid=" + empGuid + "&specGuid=" + specGuid + "&isMain=" + isMain + "&specName=" + specName + "&rand=" + Math.random());
                        $.getJSON("PersonExpSpecialityInfo.aspx", { "action": "GetSpecTitle", "id": data.Message, "rand": Math.random() }, function (data) {
                            if (data.Result == true) {
                                $("#lblTitle").html(data.Message);
                            }
                        });
                }
            });
        });

        function onBeforeExpand(note) {

            var data = note.data;
            //防止重复加载,使用isloaded 标记
            if ($("#" + note.data.id).data("isloaded")) {
                return;
            }
            manager.loadData(note.target, '../handlers/PsnEmpInfoHandler.ashx?action=Tree&pid=' + data.id);
            $("#" + note.data.id).data("isloaded", true);
        }

        function onCheck(note, checked) {
            $.getJSON("PersonExpSpecialityInfo.aspx", { "action": "GetSpecTitle", "id": note.data.id, "rand": Math.random() }, function (data) {
                if (data.Result == true) {
                    $("#lblTitle").html(data.Message);
                }
            });
        } 
    }

    function InitialTree() {
        var psid;
        specName = escape($("#<%= hidSpecName.ClientID%>").val());
        $.getJSON("PersonExpSpecialityInfo.aspx", { "action": "GetSpecDics", "empGuid": empGuid, "specGuid": specGuid, "isMain": isMain, "specName": specName, "rand": Math.random() }, function (data) {
            if (data.Result == true) {
                    manager.clear();
                    manager.loadData(null, "../handlers/PsnEmpInfoHandler.ashx?action=LoadSpecDics&empGuid=" + empGuid + "&specGuid=" + specGuid + "&isMain=" + isMain + "&specName=" + specName + "&rand=" + Math.random());
                        $.getJSON("PersonExpSpecialityInfo.aspx", { "action": "GetSpecTitle", "id": data.Message, "rand": Math.random() }, function (data) {
                            if (data.Result == true) {
                                $("#lblTitle").html(data.Message);
                            }
                        });
            }
        });
    }
    /*取得信息**/
    function GetExpSpec() {
        $.getJSON("PersonExpSpecialityInfo.aspx", { "action": "GetExpSpec", "empGuid": empGuid, "specGuid": specGuid, "isMain": isMain, "rand": Math.random() }, function (data) {
            if (data.length == 0 || data == null) {
                OpenAlert("未查询到有效数据！");
                return false;
            }
            if (data.result == 1) {
                OpenAlert(data.message);
                return false;
            }
            var items = data.data;
            if (items != null) {
                //客户端赋值
                SetControlVal("expertSpeciality", items);
                if ($("#txtEndDate").val() == "至今") {
                    $("#CheckEndTime").attr("checked", "true");
                    $("#txtEndDate").attr("disabled", "disabled");
                }
                InitialTree();
            }
        });
    }
    /*保存信息*/
    function ExpSpecSave(btnId) {
        if (empGuid == "") {
            OpenAlert("请先添加人员信息！");
            return false;
        }
        var node = manager.getChecked();
        if (node != null && node[0] != null) {
        $("#hidSpecName").val(node[0].data.text);
        $("#hidSpecCode").val(node[0].data.code);
        $("#hidTypeFlags").val(node[0].data.id);
        }
        else {
            alert("请选中专业信息");
            return false;
        }

        //验证控件值
        var dataValid = CheckControlValid(btnId);
        if (!dataValid) {
            return false;
        }
        $("#" + btnId).attr("disabled", "disabled");
        if (status == "0") {
            ExpSpecAdd(btnId, "ExpSpecAdd");
        } else {
            ExpSpecAdd(btnId, "ExpSpecEdit");
        }
    }
    /*添加修改信息*/
    function ExpSpecAdd(btnId, action) {
        var dataStr = GetData(btnId); //取得页面上输入的数据
        $.getJSON("PersonExpSpecialityInfo.aspx", { "action": action, "empGuid": empGuid, "isMain": isMain, "data": dataStr, "rand": Math.random() }, function (data) {
            $("#" + btnId).removeAttr("disabled");
            OpenAlert(data.Message);
            if (data.Result) {
                returnToParent(0);
            }
        });
    }

    /*关闭窗口*/

    function returnToParent(result) {
        var oArg = new Object();
        oArg.childWinName = "Specs";
        oArg.Result = result;
        //        top.ChildDialogCallBack = "OnClientClose";
        //        top.ChildDialogClose(oArg);
        parent.window.OnClientClose(oArg);
        window.parent.$.ligerDialog.close(); ////关闭dialog
        parent.$(".l-dialog,.l-window-mask").hide(); ////去除父窗体遮罩层
        parent.window.focus();
    }
    function OpenAlert(text) {
        $.ligerDialog.warn(text);
        return false;
    } 
</script>
